import React,{Component} from 'react'
import {PublishStyle} from './StyleMytask'
import Line from './components/Line'
import {userData} from 'userData/userData'
import connect from 'pages/redux-component/connect'


import qs from "qs";
import {
    Route,
    withRouter,
  } from 'react-router-dom'

class Publish extends Component{
    state = {
        cateList: []
    }
    render(){
        console.log(this.state.cateList)
        return(
            <PublishStyle>
            {
            this.state.cateList.map((value,index)=>{
            return(
                <Line
                key={index}
                data={value}
                handleClick={()=>this.onhandleClick(value.tid)}
                ></Line>
            )
           
            })
            }
             </PublishStyle>
        )
    }
    componentDidMount() {
        let result = fetch('/Legang/task/findbyuid',{
        
        method:"POST",
        headers:{
            "Content-type":"application/x-www-form-urlencoded"
        },
        body: qs.stringify({uid:this.props.uid})
        // "email=1486960462@qq.com&password=123456",
        })
        
        .then(response => response.json())
        .then(result => {
            console.log(result)
            if(result.flag){
                this.setState({
                    cateList: result.data
                })
            }
        })
    }
    onhandleClick(tag){     
        console.log(tag)
        this.props.history.push({pathname:'/myChildRouter/taskDetail/' + tag})
    }
}

export default withRouter(connect(Publish))